package com.agileboot.domain.airport.inspection.command;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import java.util.Date;

/**
 * @author valarchie
 */
@Data
public class AddSirInspectionCommand {

    @NotBlank(message = "检查名称不能为空")
    private String inspectionName;

    private String inspectionSource;

    private Date startTime;

    private Date endTime;

    private String inspectionContent;

    private Long inspectionDeptId;

    private String createBy;

    private Date createTime;

    private String updateBy;

    private Date updateTime;

    private String remark;

    private String status;

    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date planDate;

    private String inspectionCode;

    private Long checkCount;

    private Long checkOkCount;

    private String inspectionType;

    private String inspectionPeriod;

    private String inspectionLevel;

    private Long approver;

    private Long deptId;

    private String checkUseridList;

    private Long checkUserId;

    private Long creatorId;

    private Long updaterId;

    private Boolean deleted;

    private String type;

    private String suggestion;
    /**
     * 生成检查编号并自动设置创建时间
     */
    public void generateInspectionCode() {
        if (type != null && !type.isEmpty()) {
            String timestamp = String.valueOf(System.currentTimeMillis());
            this.inspectionCode = type.toUpperCase() + "-" + timestamp;

            // 根据 type 给 inspectionType 赋值
            switch (type.toUpperCase()) {
                case "FDZC":
                    this.inspectionType = "1";
                    break;
                case "ZXJC":
                    this.inspectionType = "2";
                    break;
                case "AQZL":
                    this.inspectionType = "3";
                    break;
                default:
                    this.inspectionType = null;
            }
        }
        // 自动设置创建时间
        this.createTime = new Date();

        this.status = "0";


    }
}